package com.nuanshui.heatedloan.extension.jpasearch;

import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;

import com.nuanshui.heatedloan.util.dwz.DwzPage;

/**
 * 字段的排序
 * 
 * @ClassName: FieldSort
 * @Description: TODO
 * @author 郭浩
 * @date 2014-10-11 下午07:31:48
 * 
 */
public class FieldSort {
	/**
	 * 字段名
	 */
	private String fieldName;
	/**
	 * 排序方式
	 */
	private String sortType;

	public String getFieldName() {
		return fieldName;
	}

	public void setFieldName(final String fieldName) {
		this.fieldName = fieldName;
	}

	public Direction getSortType() {
		if (DwzPage.ORDER_DIRECTION_ASC.equalsIgnoreCase(sortType)) {
			return Sort.Direction.ASC;
		} else {
			return Sort.Direction.DESC;
		}
	}

	public void setSortType(final String sortType) {
		this.sortType = sortType;
	}

	public FieldSort(final String fieldName, final String sortType) {
		super();
		this.fieldName = fieldName;
		this.sortType = sortType;
	}

	public FieldSort() {
		super();
	}

}
